/**
 * Created by song on 2016/10/9.
 */
angular.module('starter.controllers_manage', [])
  .controller('Manage', function($scope,$window,$ionicHistory,$timeout,CONSTANT,LS) {
    $scope.buttontext = '管理';
    $scope.module_manage = LS.getObject(CONSTANT.app_list) ;
    $scope.goBack = function(){
      $ionicHistory.goBack();
    };
    $scope.editApp = function(){
      if($scope.buttontext == '管理')
      {
        $scope.buttontext = '完成'
        $(".content-div-manage").css("border","solid 1px #D9D9D9");
        $(".manage-add-button-top").addClass('ion-android-remove-circle');
        $(".manage-add-button-bottom").addClass('ion-android-add-circle');
      }
      else {
        LS.setObject(CONSTANT.app_list,$scope.module_manage);
        $scope.buttontext = '管理'
        $(".content-div-manage").css("border","solid 1px #ffffff");
        $(".manage-add-button-top").removeClass('ion-android-remove-circle');
        $(".manage-add-button-bottom").removeClass('ion-android-add-circle');
      }
    };
    $scope.addORremove = function(flag,index){
      if(flag==1){
        $scope.module_manage[index].module_hide = false;
        $timeout(
          function() {
            $(".manage-add-button-bottom").addClass('ion-android-add-circle');
          })
      }
      else if(flag==2){
        $scope.module_manage[index].module_hide = true;
        $timeout(
          function() {
            $(".content-div-manage").css("border","solid 1px #D9D9D9");
            $(".manage-add-button-top").addClass('ion-android-remove-circle');
          });
      }
    };
  })
